<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>联系人</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/timeago.js"></script>
  </head>
  
  <body>
    <%@include file="include/topbar.jsp" %>

	<div class="container" style="margin-top: 60px">
			<div class="row">
				<jsp:include page="include/left.jsp">
					<jsp:param value="contact" name="tag"/>
				</jsp:include>
				
		<div class="span9">
			<form class="form-horizontal" id="contactform"  name="contactform">
        <fieldset>
          <legend>添加新联系人</legend>
          <div class="control-group">
            <label for="input01" class="control-label">姓名</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input01" class="span5" name="name" />
            </div>
          </div>
		   <div class="control-group">
            <label for="input01" class="control-label">公司</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input02" class="span5" name="company" />
            </div>
          </div>
		  <div class="line"></div>
		   <div class="control-group">
            <label for="input01" class="control-label">手机</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input03" class="span5" name="" />
            </div>
          </div>
		   <div class="control-group">
            <label for="input01" class="control-label">固话</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input04" class="span5" />
            </div>
          </div>
		  <div class="control-group">
            <label for="input01" class="control-label">邮箱</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input05" class="span5" />
            </div>
          </div>
		   <div class="line"></div>
		  <div class="control-group">
            <label for="input01" class="control-label">地址</label>
            <div class="controls">
              <input type="text" x-webkit-speech="undefined" id="input06" class="span5" />
            </div>
          </div>
		   <div class="line"></div>
		   <div class="control-group">
            <label for="input01" class="control-label">主页</label>
            <div class="controls">
              <input type="text" value="" id="input07" class="span5" />
			  <p class="help-block">http://www.xxx.com</p>
            </div>
          </div>
		   <div class="control-group">
            <label for="input01" class="control-label">微博</label>
            <div class="controls">
				<select class="span2">
					<option></option>
					<option>新浪微博</option>
					<option>腾讯微博</option>
					<option>Twitter</option>
				</select>
				<div class="input-prepend">
					<span class="add-on">@</span><input type="text" x-webkit-speech="undefined" size="16" id="input08" class="span2" />
                </div>
				
            </div>
          </div>
		   <div class="control-group">
            <label for="input01" class="control-label">简介</label>
            <div class="controls">
              <textarea rows="6" class="span5" id="input09"></textarea>
            </div>
          </div>
		  
		  

          <div class="form-actions">
            <a class="btn btn-primary" id="savecontact">保存</a>
            <button onclick="location.back()" class="btn">返回</button>
          </div>
        </fieldset>
      </form>          
          	
		</div>
		</div>
		</div>
	<script type="text/javascript">
		$(function() {
			$("#savecontact").click(function() {
				var name = $("#input01").val();
				var company = $("#input02").val();
				var moblie = $("#input03").val();
				var tel = $("#input04").val();
				var email = $("#input05").val();
				var address = $("#input06").val();
				var website = $("#input07").val();
				var weibo = $("#input08").val();
				var content = $("#input09").val();
				
				if(name.trim() == "" || company.trim() == "" || moblie.trim() == "" || tel.trim() == "" || email.trim() == "") {
					alert("*必须要填写");
				} else {
					$.ajax({
						url : 'addcontact.jspx',
						type : 'POST',
						data : {
							name : name,
							company : company,
							moblie : moblie,
							tel : tel,
							email : email,
							address : address,
							website : website,
							weibo : weibo,
							content : content
						}
					}).done(function(msg) {
						if(msg == 1002) {
							alert("添加失败");
						} else {
							window.location = "contact.jspx";
						}
					});
				}
			});
		});
	</script>		
  </body>
</html>
